//
//  DZDCell.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2021/9/27.
//  Copyright © 2021 zwb. All rights reserved.
//

import UIKit
 
class ZyaDZDCell: UITableViewCell {
    lazy var bg:UIView = {
       let v = UIView()
        v.layer.cornerRadius = 5
        v.layer.borderColor = Theme.primaryColor().cgColor
        v.layer.borderWidth = 1
        return v
    }()
   lazy var left1:UILabel = {
      let v = UILabel()
       v.text = "--"
       v.font = UIFont.systemFont(ofSize: 15)
        return v
   }()
    lazy var left2:UILabel = {
       let v = UILabel()
        v.text = "--"
        v.font = UIFont.systemFont(ofSize: 15)
         return v
    }()
    lazy var left3:UILabel = {
       let v = UILabel()
        v.text = "--"
        v.font = UIFont.systemFont(ofSize: 15)
         return v
    }()
    lazy var left4:UILabel = {
       let v = UILabel()
        v.text = "--"
        v.font = UIFont.systemFont(ofSize: 15)
         return v
    }()
    lazy var right1:UILabel = {
       let v = UILabel()
        v.text = "--"
        v.font = UIFont.systemFont(ofSize: 15)
         return v
    }()
    lazy var right2:UILabel = {
        let v = UILabel()
         v.text = "--"
         v.font = UIFont.systemFont(ofSize: 15)
          return v
     }()
   
   override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
       super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.addSubview(bg)
        bg.snp.makeConstraints { make in
           make.top.equalTo(self.contentView).offset(6)
           make.left.equalTo(self.contentView).offset(10)
           make.right.equalTo(self.contentView).offset(-10)
           make.bottom.equalTo(self.contentView)
       }
       bg.addSubview(left1)
       bg.addSubview(left2)

       bg.addSubview(left3)

       bg.addSubview(left4)

       bg.addSubview(right1)

       bg.addSubview(right2)

       left1.snp.makeConstraints { make in
           make.left.equalTo(bg).offset(10)
           make.top.equalTo(bg).offset(9)
          }
       left2.snp.makeConstraints { make in
           make.left.equalTo(bg).offset(10)
           make.top.equalTo(left1.snp.bottom).offset(9)
          }
       left3.snp.makeConstraints { make in
           make.left.equalTo(bg).offset(10)
           make.top.equalTo(left2.snp.bottom).offset(9)
          }
       left4.snp.makeConstraints { make in
           make.left.equalTo(bg).offset(10)
           make.top.equalTo(left3.snp.bottom).offset(9)
          }
       right1.snp.makeConstraints { make in
           make.right.equalTo(bg).offset(-10)
           make.centerY.equalTo(left1)
          }
       right2.snp.makeConstraints { make in
           make.right.equalTo(bg).offset(-10)
           make.centerY.equalTo(left4)
           }
     
   }
   var one:ZyaHomePageDetail? {
       didSet {
           if let one = one {
               left1.text = one.typename.unwrap + "  " +  one.sNo.unwrap
               left2.text =  one.orgName.unwrap
               left3.text = "应付(元)  " + one.sSockMoney.unwrap
               left4.text =  "已付(元)  " +  one.sYfMoney.unwrap
               right1.text =  one.sDate.unwrap
 
               let labelText = "待付(元)  " + one.sDfMoney.unwrap
              let smokedLimitAttr1 = NSMutableAttributedString(string: labelText)
        
            smokedLimitAttr1.addAttribute(NSAttributedString.Key.font, value: UIFont.systemFont(ofSize: 18), range: (labelText as NSString).range(of: one.sDfMoney.unwrap))
               smokedLimitAttr1.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.red, range: (labelText as NSString).range(of: one.sDfMoney.unwrap))
               right2.attributedText = smokedLimitAttr1
 
               
            }
       }
   }
   
   required init?(coder: NSCoder) {
       fatalError("init(coder:) has not been implemented")
   }
   
   override func setSelected(_ selected: Bool, animated: Bool) {
       super.setSelected(selected, animated: animated)

       // Configure the view for the selected state
   }

}
